package network;

import javax.print.DocFlavor;
import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2025-03-01
 * Time: 17:29
 */
public class UdpDictServer extends UdpEchoServer{
    private Map<String, String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("pig","小猪");
        dict.put("fuck","卧槽");
    }
    // 是要复用之前的代码, 但是又要做出一些调整
    @Override
    public String process(String request) {
        // 把请求对应单词的翻译给返回回去
        return dict.getOrDefault(request, "该词没有查询到");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
